var url = 'ws://192.168.0.105:8501';

var websocket = new WebSocket(url);
//实例化对象的onopen事件
websocket.onopen = function (evt) {
    console.log("conected-swoole-success");
}
//实例化对象的onmessage事件
websocket.onmessage = function (evt) {
    //evt.data
    //todo
    push(evt.data);
    console.log("ws-server-return-data:" + evt.data);
}
//实例化对象的onclose事件
websocket.onclose = function (evt) {
    console.log("close");
}
//实例化对象的onerror事件
websocket.onerror = function (evt, e) {
    console.log("error:" + evt.data);
}

function push(data) {
    data = JSON.parse(data);
    html = '<div class="frame">';
    html += '<h3 class="frame-header">';
    html += '<i class="icon iconfont icon-shijian"></i>第' + data.type + '节 00：00';
    html += '</h3>';
    html += '<div class="frame-item">';
    html += '<span class="frame-dot"></span>';
    html += '<div class="frame-item-author">';
    if (data.logo) {
        html += '<img src="' + data.logo + '" width="20px" height="20px" /> ';
    }
    html += data.title;
    html += '</div>';
    html += '<p>' + data.content + '</p>';
    html += '</div>';
    html += '</div>';

    $('#match-result').prepend(html);

}